import axios from '@/util'; 

import type {
  RoleEntity,
} from './typings';



/**
 * 查询 role 列表 GET /api/role/list
 */
export async function get_api_role_list (
  options?: Record<string, any>,
): Promise<RoleEntity> {
  return axios({
    method: 'GET',
    url: `/api/role/list`,
    ...(options || {}),
  })
}

/**
 * 查询单个角色详情及权限菜单 GET /api/role/one/{id}/perms
 */
export async function get_api_role_one__id__perms (
  pathVars: {
    /**  */
    id: any;
  },
  options?: Record<string, any>,
): Promise<RoleEntity> {
  return axios({
    method: 'GET',
    url: `/api/role/one/${pathVars.id}/perms`,
    ...(options || {}),
  })
}

/**
 * 创建角色 POST /api/role
 */
export async function post_api_role (
  data: {
    /** 角色名称 */
    name?: string;
    /** 角色备注 */
    remark?: string;
    /** 当前角色所拥有的菜单组 */
    menuIds?: string__;
  },
  options?: Record<string, any>,
): Promise<RoleEntity> {
  return axios({
    method: 'POST',
    url: `/api/role`,
    data: {
      ...data,
    },
    ...(options || {}),
  })
}

/**
 * 更新角色 PUT /api/role
 */
export async function put_api_role (
  data: {
    /** id */
    id?: string;
    /** 角色名称 */
    name?: string;
    /** 角色备注 */
    remark?: string;
    /** 当前角色所拥有的菜单组 */
    menuIds?: string__;
  },
  options?: Record<string, any>,
): Promise<any> {
  return axios({
    method: 'PUT',
    url: `/api/role`,
    data: {
      ...data,
    },
    ...(options || {}),
  })
}

/**
 * 删除角色 DELETE /api/role/{id}
 */
export async function delete_api_role__id_ (
  pathVars: {
    /**  */
    id: any;
  },
  options?: Record<string, any>,
): Promise<any> {
  return axios({
    method: 'DELETE',
    url: `/api/role/${pathVars.id}`,
    ...(options || {}),
  })
}
